package com.agentpad;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.ListAdapter;
import android.widget.TextView;

public class HouseListAdapter extends ArrayAdapter<House> {
//	private Context ctx;
//	List<House> houses = new ArrayList<House>();
	
	public HouseListAdapter(Context ctx, List<House> houses)
	{
		super(ctx, android.R.layout.simple_expandable_list_item_1, houses);
//		this.ctx = ctx;
//		
//		if(houses != null)
//			this.houses = houses;
	}

	@Override
	public View getView(int pos, View convertView, ViewGroup parent) {
		TextView v = (TextView)super.getView(pos, convertView, parent);

		House house = this.getItem(pos);
		v.setText(house.getName() + "/" + house.getAddr());
		
		// v.setTextColor(0x00FF00);
		
		return v;
	}
	
//	public boolean addHouse(House house)
//	{
//		return houses.add(house);
//	}
//	
//	public House removeHouse(int pos)
//	{
//		return houses.remove(pos);
//	}
//
//	public boolean removeHouse(House house)
//	{
//		return houses.remove(house);
//	}
//	
	public House getHouse(int pos)
	{
		return (House)getItem(pos);
	}
}
